今天主要分享我自己在工作機上常用的 vim設定,我沒有設定得很複雜,能讓文件簡單清楚顯示就是我的目標。畢竟我沒有打算將 vim 變成 IDE的夢想。
:%s/search_from/replace_to/g
註解 "
雙引號
" 這是註解
有時候撰寫 yaml 文件就會手癢按下 tab
,我覺的這個功能對我來說非常重要。
set et " expandtab,用空格代替Tab鍵
會自動識別語法,我想是依據副檔名吧。
syntax enable
set cursorline
set cursorcolumn
打開未知的中文文件編碼非常重要,不然會出現一片亂碼。
" 自動判斷編碼
set fileencodings=utf-8,utf-16,big5,gb2312,gbk,gb18030,euc-jp,euc-kr,latin1
if has("multi_byte")
else
echoerr "If +multi_byte is not included, you should compile Vim with big features."
endif
set encoding=utf-8
雖然 vim 右下角忌諱顯示行號,但是在每行的左邊要跟 PM 或是跟同事溝通時會比較方便。
set nu
set wrap " 自動換行
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall
" Vundle start
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Your plugin start
" Your plugin end
call vundle#end() " required
filetype plugin indent on " required
" Vundle end
常常用 markdown 作筆記下面這幾個套件很實用。
Plugin 'gabrielelana/vim-markdown'
Plugin 'tyru/open-browser.vim'
Plugin 'kannokanno/previm'
Plugin 'preservim/nerdtree'
ctrl + w + h 光標 focus 左側樹形目錄
ctrl + w + l 光標 focus 右側文件顯示窗口
ctrl + w + w 光標自動在左右側窗口切換
ctrl + w + r 移動當前窗口的佈局位置
最後附上我自己的設定
" 個人化設定
set et " expandtab,用空格代替Tab鍵
set background=dark
set cursorline " 顯示游標所在的列
set cursorcolumn " 顯示游標所在的行
set wrap " 自動換行
set nu " 自動換行
set t_Co=256 " 指定 vim 的顏色
" 自動判斷編碼
set fileencodings=utf-8,utf-16,big5,gb2312,gbk,gb18030,euc-jp,euc-kr,latin1
if has("multi_byte")
else
echoerr "If +multi_byte is not included, you should compile Vim with big features."
endif
set encoding=utf-8
" Vundle start
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
" Your plugin start
" NERDTree
autocmd vimenter * NERDTree " 自動開啟Nerdtree
let g:NERDTreeWinSize = 25 " 設定 NERDTree 視窗大小
map <F5> :NERDTreeToggle<CR> " 開啟/關閉nerdtree快捷鍵
autocmd vimenter * if !argc()|NERDTree|endif " 開啟vim時如果沒有檔案自動開啟NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif "當NERDTree為剩下的唯一視窗時自動關閉
let g:NERDTreeDirArrowExpandable = '▸' " NERDTree 圖標
let g:NERDTreeDirArrowCollapsible = '▾' " NERDTree 圖標
let g:NERDTreeHidden=0 "不顯示隱藏檔案
" let NERDTreeMinimalUI = 1
" let NERDTreeDirArrows = 1
let g:NERDTreeNodeDelimiter = "\u00a0"
" git
Plugin 'airblade/vim-gitgutter'
set updatetime=200 " 每兩秒檢查一次有差異
highlight GitGutterAdd ctermfg=blue
highlight GitGutterChange ctermfg=green
highlight GitGutterDelete ctermfg=red
" nerdtree
Plugin 'preservim/nerdtree'
" Your plugin end
call vundle#end() " required
filetype plugin indent on " required
" Vundle end
Make Vim as Your Bash-IDE Using bash-support Plugin